import { ActionContext } from 'vuex';

const state = {
  loading: false,
  adminCount: 0,
}
export type stateType = typeof state;

const getters = {}

const mutations = {
  addAdminCount(state: stateType) {
    console.log({ state })
    state.adminCount += 1;
    console.log({ state })
  },
  setLoading(state: stateType, payload: boolean) {
    console.log(payload)
    state.loading = payload
  }
}

const actions = {
  fakeFeatch({ commit }: ActionContext<stateType, unknown>): void {
    console.log(123)
    commit('setLoading', true);
    console.log(2)
    setTimeout(function () {
      console.log(3)
      commit('addAdminCount');
      console.log(4)
      commit('setLoading', false);
    }, 3000);
  }
}

const modules = {}

export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions,
  modules,
}